package edu.ctbu.ctbujsj.service;

import edu.ctbu.ctbujsj.dao.StudentRepository;
import edu.ctbu.ctbujsj.domain.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.sql.Timestamp;
import java.util.List;
@Service
public class StudentService {
    @Autowired
    private StudentRepository studentRepository;

    /**
     * 数据库所有数据
     * @return
     */

    public List<Student> findAll(){
        return studentRepository.findAll();
    }

    public List<Student>findByFixTrueName(String affixName){
       //List<Student> myList=studentRepository.findByTrueNamelike( affixName+"%");
        List<Student> myList=studentRepository.findByTrueNameLike(affixName+"%");
        return myList;
    }

    /**
     *
     * @param start
     * @param end
     * @return
     */
    public List<Student>findByBirthdayBetween(Timestamp start,Timestamp end){
        List<Student> myList=studentRepository.findByBirthdayBetween(start,end);
        return myList;
    }

    /**
     *
     * @return
     */
    public List<Student>findByMaxNum(){
        List<Student> myList=studentRepository.findByMaxName();
        return myList;
    }

    /**
     *
     * @param name
     * @param sex
     * @return
     */
    public List<Student>findByNameAndSex(String name,long sex){
        List<Student> myList=studentRepository.findByNameAndSex(name,sex);
        return myList;
    }
}
